
********************************************************************************************************************************
						
														***Marlene Mauk, Max Groemping***
			***Online Disinformation Predicts Inaccurate Beliefs about Election Fairness among Winners and Losers***
											***Replication File  ##2 - MEASUREMENT MODELS 1***
						
********************************************************************************************************************************


** exporting data to Mplus to run measurement models
use mergeddata.dta
stata2mplus id eleid elecow pef1 pef2 pef6 pef7 pef8 v2smgovdom v2smfordom v2smpardom using pefdisinfo, missing(999) replace

collapse pei* eleyear, by(eleid)
sum pei*
expand 3 if eleid==336 /*create two hypothetical countries with electoral integrity of 0 and 1 to provide scaling benchmark for mplus factors*/
gen id = _n
replace eleid=998 if id==83 | id==84
replace pei1=0 if id==83
replace pei2=0 if id==83
replace pei6=0 if id==83
replace pei7=0 if id==83
replace pei8=0 if id==83
replace pei1=1 if id==84
replace pei2=1 if id==84
replace pei6=1 if id==84
replace pei7=1 if id==84
replace pei8=1 if id==84
stata2mplus eleyear eleid pei* using pei, missing(999) replace
clear

use pei_exp.dta
stata2mplus eleid pei* using pei_exp, missing(999) replace
clear
